
import { storage } from "@/utils/storage";
import store from "@/store";
/*
*@method 设置token
*@param  token  
*@return
*/
export const setToken = (token)=> {
  storage.local.set(storage.events.token, token);
}
/*
*@method 获取token
*@return token
*/
export const getToken = ()=> {
  return storage.local.get(storage.events.token);
}

/*
*@method 设置refreshToken
*@param  refreshToken  
*@return
*/
export const setRefreshToken = (token)=> {
  storage.local.set(storage.events.refreshToken, token);
}

/*
*@method 设置refreshToken
*@return refreshToken
*/
export const getRefreshToken = ()=> {
  return storage.local.get(storage.events.refreshToken);
}


/*
*@method 登出需要清除一些数据
*@return 
*/
export const logoutClear = ()=> {
  // 清除token
  storage.local.remove(storage.events.token);
  // 清除refreshToken
  storage.local.remove(storage.events.refreshToken);
  storage.local.remove(storage.events.node);
  storage.local.remove(storage.events.moduleId);
  storage.local.remove(storage.events.tagview);
  store.dispatch('layout/clear')
}

/*
*@method 按钮权限过滤
*@return 
*/
export const fliterPermission = (data)=> {
  return store.getters['permission/fliterPermission'](data);
}

/* 维度统一获取入口， 其他地方调用获取维度均可视为不规范操作
* @param {String} code 维度编码
*/
export const getDimensionByCode = (code)=> {
  return store.getters['dimension/getDimensionByCode'](code);
}

